import { http } from "@/utils/http";

export type commonResult<T> = {
  code: number;
  msg: string;
  result: T;
};

export type infoType = {
  systematicId?: any;
  DeviceIcon: number;
  place?: any;
  capture:any;
  deviceIconInfo:any;
  flowCardNum?: any;
  unityId?: any;
  modelId?: any;
  id?: number;
  markPoint?: any;
  productName: string;
  deviceName?: string;
  lat: string;
  lng: string;
  productId?: number;
  prodcutName?: string;
  area: string;
  deviceSN?: string;
  connectStatus?: number;
  systemId?: number;
  insidePosition?: string;
  systemName?: string;
  status?: number;
  positionInfo?: object;
  gatewayInfo?: object;
  productInfo?: object;
  flowCardInfo?: object;
  projectId: number;
  position?: number;
  outsidePostion?: string;
  buildingId?: any;
  drawingId?:any;
  drawingPoint?: any;
  mapPoints?: string;
  gatewayId: number;
  expireDate?: string;
  rate?: any;
  addressCode?: any;
  flowCardId?: string;
  remark?: string;
  monitorId?: number;
  deviceImg?: string;
  dutyUid?: any;
  dviceAliases?: string;
  netWorkMode?: number;
  deviceKind?: number;
};
export type infoTypeList = {
  data: infoType[];
  total: number;
};

const List = "/business/device/device/v2/devices";
const Url = "/business/device/device/v2/device";
export const getList = (params?: object) => {
  return http.request<commonResult<infoTypeList>>("get", List, {
    params
  });
};
export const getInfo = (params?: object) => {
  return http.request<commonResult<infoType>>("get", Url, {
    params
  });
};
export const addInfo = (data?: object) => {
  return http.request<commonResult<any>>("post", Url, {
    data
  });
};
export const editInfo = (data?: object) => {
  return http.request<commonResult<any>>("put", Url, {
    data
  });
};
export const deleteInfo = (data?: object) => {
  return http.request<commonResult<any>>("delete", Url, {
    data
  });
};
//关联视频 /business/device/device/v2/monitor
export const getMonitor = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/monitor",
    {
      params
    }
  );
};
//设备位置 /business/device/device/v2/position
export const getPosition = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/position",
    {
      params
    }
  );
};
//查看设备信息 /business/device/device/v2/device-info
export const getDeviceInfo = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/device-base",
    {
      params
    }
  );
};
//下载导入模板 /business/device/device/v2/down-load
export const getDownLoad = (data?: object) => {
  return http.request<commonResult<any>>(
    "post",
    "/business/device/device/v2/down-load",
    {
      data
    }
  );
};
//导入设备 /business/device/device/v2/import
export const getImport = (data?: object) => {
  return http.request<commonResult<any>>(
    "post",
    "/business/device/device/v2/import",
    {
      data
    }
  );
};
//所属网关下拉框
export const getGatewayops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/gateway-ops",
    {
      params
    }
  );
};
//关联监控下拉框
export const getMonitorops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/monitor-ops",
    {
      params
    }
  );
};
//通过序列号查询设备
export const getDeviceBySn = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/product",
    {
      params
    }
  );
};
//所属楼层下拉框
export const drawingops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/drawing-ops",
    {
      params
    }
  );
};
//所属建筑下拉框
export const buildingops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/building-ops",
    {
      params
    }
  );
};
//设备位置
export const getDevicePosition = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/position",
    {
      params
    }
  );
};
//关联视频
export const getVideoops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/monitor",
    {
      params
    }
  );
};
//控制指令下发
export const getControlops = (data?: object) => {
  return http.request<commonResult<any>>(
    "post",
    "/business/device/v2/control/command",
    {
      data
    }
  );
};
//2.8.2.23获取图标 /business/device/device/v2/device-type
export const getDeviceTypeops = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/device-type",
    {
      params
    }
  );
};
//获取实时数据信息

export const currentdata = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/v2/data/current",
    {
      params
    }
  );
};
/** 2.8.2.24设备列表的搜索框系统下拉框  */  
export const systemdevice = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/device/v2/system-op",
    {
      params
    }
  );
};

/** 2.8.2.3下载导入模板 */
export const download = (params?: object) => {
  return http.request<Blob>("get", '/business/device/device/v2/down-load', {
    params,
     responseType: 'blob'
  });
};

/** 2.8.2.2导入设备 */
export const importDevice = (data?: object) => {
  return http.request<commonResult<any>>("post", '/business/device/device/v2/import', {
    data,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  });
}
/** 2.8.3.7 查询用传的产品类型 */
export const gatewayproduct = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/gateway/v2/product",
    {
      params
    }
  );
};
/** 2.8.3.8根据产品类型查询系统 */  
export const gatewaysystemtic = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/device/gateway/v2/systemtic",
    {
      params
    }
  );
};

/** 2.10.5 设备告警统计 */
export const getdevicealarm = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "/business/statistics/v2/device-alarm",
    {
      params
    }
  );
};
/** 2.8.2.25 控制命令配置读取  */
export const commandconfig = (params?: object) => {
  return http.request<commonResult<any>>(
    "get",
    "business/device/device/v2/command-config",
    {
      params
    }
  );
};